package com.example.expresscheck.adapter;

import com.example.expresscheck.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterExpressTel extends BaseAdapter {
	Context context;
	String[] companyLogos;
	String[] companyNames;
	String[] companyTel;

	public AdapterExpressTel(Context context) {
		this.context = context;
		companyTel = context.getResources().getStringArray(R.array.company_tel);
		companyNames = context.getResources().getStringArray(
				R.array.company_name);
		companyLogos = context.getResources().getStringArray(
				R.array.company_logo);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return companyTel.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int index, View arg1, ViewGroup arg2) {
		View itemView = LayoutInflater.from(context).inflate(
				R.layout.item_express_tel, null);
		TextView company_name = (TextView) itemView
				.findViewById(R.id.tv_item_company_name);
		TextView company_tel = (TextView) itemView
				.findViewById(R.id.tv_item_company_tel);
		ImageView company_logon = (ImageView) itemView
				.findViewById(R.id.iv_item_logo);
		company_tel.setText(companyTel[index]);
		company_name.setText(companyNames[index]);
		company_logon.setBackgroundResource(context.getResources()
				.getIdentifier(
						"com.example.expresscheck:drawable/"
								+ companyLogos[index], null, null));
		return itemView;
	}

}
